Skip to content

Conversation

@gagik
Copy link

@gagik gagik commented May 20, 2025

This is still code that is largely skunkworks-quality so will probably go through a couple more refactors before it's ready to be reviewed / merged but it's quite functional!

One can install this snippet using the snippet command in mongosh:

# Set your snippet sources
config.set('snippetIndexSourceURLs', config.get('snippetIndexSourceURLs') +
'; https://github.com/gagik/mongosh-snippets/raw/refs/heads/ai/index.bson.br'
 )
# Install the ai snippet
snippet install ai
# Check out the commands!
ai.help

@gagik gagik marked this pull request as draft May 20, 2025 11:31
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind that this package-lock file has no practical effect 🙂

const { getAiSdkProvider, models } = localRequire<typeof import('./providers/generic/ai-sdk-provider.js')>('./providers/generic/ai-sdk-provider.js');
const { Config } = localRequire<typeof import('./config.js')>('./config.js');
const { wrapAllFunctions } = localRequire<typeof import('./helpers.js')>('./helpers.js');
const chalk = localRequire<typeof import('chalk')>('chalk');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need localRequire in any file except the main entry point (index.js)

Comment on lines +12 to +13
| `ai.query` | Generate a MongoDB query | `ai.query find documents where name = "Ada"` |
| `ai.aggregate` | Generate a MongoDB aggregation | `ai.aggregate find documents where name = "Ada"` |
Copy link

@mongodben mongodben Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo data, query, and aggregate should just be 1 command since its all just a type of query

Copy link
Author

@gagik gagik Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I definitely want to reduce the command types, they have gone overboard.

in your experience, is there no benefit to doing extra prompting for i.e. at least the aggregate function?

| `ai.query` | Generate a MongoDB query | `ai.query find documents where name = "Ada"` |
| `ai.aggregate` | Generate a MongoDB aggregation | `ai.aggregate find documents where name = "Ada"` |
| `ai.collection` | Set the active collection | `ai.collection("users")` |
| `ai.shell` | Generate general mongosh commands | `ai.shell get sharding info` |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming: perhaps ai.command instead?

| `ai.aggregate` | Generate a MongoDB aggregation | `ai.aggregate find documents where name = "Ada"` |
| `ai.collection` | Set the active collection | `ai.collection("users")` |
| `ai.shell` | Generate general mongosh commands | `ai.shell get sharding info` |
| `ai.general` | Ask general questions to your model | `ai.general what is the meaning of life?`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why include this?

Copy link
Author

@gagik gagik Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I remove this from the code but haven't update the docs.
agree for sake of the snippet I'll remove that. I added a bunch of these to play around with different providers (it also made more sense when I originally was just using non-docs general AI providers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants